package cn.lx.elasticsearch.autocomplete.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.CompletionField;
import org.springframework.data.elasticsearch.core.completion.Completion;

/**
 * 城市实体类 - 用于演示地理位置自动补全
 * 
 * @author lx
 * @since 2024-01-01
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "cities")
public class City {

    @Id
    private String id;

    /**
     * 城市名称 - 用于自动补全
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String name;

    /**
     * 自动补全字段 - 真正的 completion 字段
     */
    @CompletionField(maxInputLength = 50)
    private Completion nameSuggest;

    /**
     * 省份
     */
    @Field(type = FieldType.Keyword)
    private String province;

    /**
     * 国家
     */
    @Field(type = FieldType.Keyword)
    private String country;

    /**
     * 城市代码
     */
    @Field(type = FieldType.Keyword)
    private String code;

    /**
     * 人口数量
     */
    @Field(type = FieldType.Long)
    private Long population;

    /**
     * 城市等级：1-一线，2-二线，3-三线，4-四线
     */
    @Field(type = FieldType.Integer)
    private Integer level;

    /**
     * 经度
     */
    @Field(type = FieldType.Double)
    private Double longitude;

    /**
     * 纬度
     */
    @Field(type = FieldType.Double)
    private Double latitude;

    /**
     * 城市描述
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String description;
}
